#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char** argv){
	int i;
	if(argc!=3){
		printf("Parameters number error!\n");
		printf("argc=%d",argc);
	}else{
		FILE *r = NULL;
		FILE *w = NULL;
		char buff[255];
   		r = fopen(argv[1], "r");
   		w = fopen(argv[2], "w");
   		if(r==NULL | w==NULL){
   			printf("File open failed!\n");
   		}else{
   			int i=0;
   			do{
   				if(NULL==fgets(buff, 255, (FILE*)r)){
   					if(i)break;
   					printf("File read failed!\n");
   					//printf("buff=%s\n",buff);//test
   					//printf("i=%d\n",i);//test
   				}else if(-1==fputs(buff, w)){
   					printf("File write failed!\n");
   				}
   				i++;
   				strcpy(buff,"");
			   }while(!feof(r));
   			
   			fclose(r);
   			fclose(w);
   		}
   	}
   	return 0;
   }
